{extend name="../../admin/view/main"}
{block name="button"}
<!--{if auth("add")}-->
<button data-modal="{:url('add')}" class='layui-btn layui-btn-sm layui-btn-primary'>添加模板</button>
<!--{/if}-->
<!--{if auth("del")}-->
<!--<button data-update data-field='delete' data-action='{:url("del")}' class='layui-btn layui-btn-sm layui-btn-primary'>删除规则</button>-->
<!--{/if}-->
{/block}
{block name='content'}

<div class="think-box-shadow">
    {include file='wechat_wechat_template/index_search'}
    {empty name='list'}
    <blockquote class="layui-elem-quote">没 有 记 录 哦！</blockquote>
    {else}

    <form autocomplete="off" onsubmit="return false;" data-auto="true" method="post" onsubmit="return false" >
        <input type="hidden" value="resort" name="action"/>
        <table class="layui-table" lay-skin="line">
            <thead>
            <tr>
                <th class='list-table-check-td think-checkbox'>
                    <input data-auto-none="" data-check-target='.list-check-box' type='checkbox'/>
                </th>

                <th class="text-left nowrap">编号</th>
                <th class="text-left nowrap"style="width: 100px">模板key</th>
                <th class="text-left nowrap">模板标题</th>
                <th class="text-left nowrap">创建时间</th>
                <th class="text-left nowrap">操作</th>
            </tr>
            </thead>
            <tbody>
            {foreach $list as $key=>$vo}
            <tr>
                <td class='list-table-check-td think-checkbox'>
                    <input class="list-check-box" value='{$vo.id}' type='checkbox'/>
                </td>
                <td class='text-left nowrap'>
                    {$vo.id}
                </td>
                <td class='text-left nowrap'style="width: 100px">
                    {$vo.tmpl_key}
                </td>
                <td class='text-left nowrap'>
                    {$vo.title}
                </td>
                <td class='text-left nowrap'>
                    {$vo.created_at}
                </td>

                <td class='text-left nowrap'>
                    {if auth("edit")}
                    <a class="layui-btn layui-btn-xs" data-title="编辑模板" data-modal='{:url("edit")}?id={$vo.id}'>编辑</a>
                    {/if}
                    {if auth("del")}
                    <a class="layui-btn layui-btn-xs layui-btn-warm" data-update="{$vo.id}" data-field='delete' data-action='{:url("del")}'>删除</a>
                    {/if}
                </td>
            </tr>
            {/foreach}
            </tbody>
        </table>
        {/empty}
        <!--{/if}-->
    </form>
</div>
{/block}

<script>
    $(function () {

        /*! 删除关键字 */
        $('[data-delete]').on('click', function () {
            var id = this.getAttribute('data-delete');
            var url = this.getAttribute('data-action');
            var dialogIndex = $.msg.confirm('确定要删除这条记录吗？', function () {
                $.form.load(url, {id: id}, 'post', function (ret) {
                    if (ret.code === "SUCCESS") {
                        window.location.reload();
                    }
                    $.msg.close(dialogIndex);
                });
            })
        });
    });
</script>
